package org.wenhuayuan.project.main.demo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.activity_demo_data_item.*
import org.wenhuayuan.project.main.R
import org.wenhuayuan.project.main.demo.demoDataItem.*
import org.wenhuayuan.uilibrary.hiitem.HiAdapter
import org.wenhuayuan.uilibrary.hiitem.HiDataItem

class DemoDataItemActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_demo_data_item)

        val hiAdapter = HiAdapter(this)
        recycler_view.layoutManager = GridLayoutManager(this, 2)
        recycler_view.adapter = hiAdapter

        val topTabDataItem = TopTabDataItem(ItemData())
        val topBanner = TopBanner(ItemData())
        val gradDataItem = GridDataItem(ItemData())

        var dataSets = ArrayList<HiDataItem<*, *>>()
        dataSets.add(topTabDataItem)
        dataSets.add(topBanner)
        dataSets.add(gradDataItem)

        dataSets.add(ActivityDataItem(ItemData()))
        dataSets.add(ItemTabDataItem(ItemData()))

//        for (i in 0..9) {
//            if (i % 2 == 0) {
//                dataSets.add(VideoDataItem(1, null))
//            } else {
//                dataSets.add(ImageDataItem(1, null))
//            }
//        }

        hiAdapter.addItems(dataSets as ArrayList<HiDataItem<*, RecyclerView.ViewHolder>>, false)
    }
}
